﻿using Service;
using System;
using System.Collections.Generic;

namespace RedisTransaction
{
    class Program
    {
        static void Main(string[] args)
        {
            TransactionService service = new();
            Dictionary<string, string> mKvs = new()
            {
                { "a", "c" },
                { "b", "n" },
                { "c", "m" }
            };

            Dictionary<string, string> kvs = new()
            {
                {"a", "1" },
                {"b", "2" },
                {"c", "3" }
            };
           
            service.SetStringNoMonitor(mKvs,(kv) =>
            {
                Console.WriteLine($"设置键值>>{ kv.Key }:{ kv.Value }");
            });
            Console.WriteLine($"初始化键值完成");

            service.CreateStringMonitor(mKvs);
            Console.WriteLine("加锁...");

            service.SetString(kvs, (kv) =>
            {
                Console.WriteLine($"设置键值>>{ kv.Key }:{ kv.Value }");
            });

            Console.WriteLine(service.Execute() ? "事务提交成功" : "事务提交失败");
            Console.ReadLine();
        }
    }
}
